#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,p[100005],q[100005],t1,t2=0,t3=INT_MAX,cnt,ans,T;
struct car{
 int di,vi,ai;
}c[100005];
int main(){
 freopen("detect.in","r",stdin);
 freopen("detect.out","w",stdout);
 cin>>T;
 for(int a=1;a<=T;a++){
  t1=0;
  t2=0;
  t3=INT_MAX;
  cnt=0;
  ans=0;
  cin>>n>>m>>L>>V;
  for(int i=1;i<=n;i++){
   cin>>c[i].di>>c[i].vi>>c[i].ai;
  }
  for(int i=1;i<=m;i++){
   cin>>p[i];
   q[p[i]]=1;
  }
  for(int i=1;i<=L;i++){
   q[i]=q[i-1]+q[i];
  }
  for(int i=1;i<=n;i++){
   if(c[i].ai==0){
    if(c[i].vi>V&&q[L]-q[c[i].di]){
     cnt++;
     t1=max(t1,c[i].di);
    }
   }
   if(c[i].ai>0){
    if(c[i].vi>V&&q[L]-q[c[i].di]){
     cnt++;
     t1=max(t1,c[i].di);
    }
    else{
    double v=sqrt(c[i].vi*c[i].vi+2*c[i].ai*(L-c[i].di));
    int t=(V*V-c[i].vi*c[i].vi)/(2*c[i].ai)+c[i].di;
     if(v>V&&q[t]-q[c[i].di]){
      cnt++;
      t1=max(t1,t+1);
     }
    }
   }
   if(c[i].ai<0){
    if(c[i].vi>V){
     int t=(V*V-c[i].vi*c[i].vi)/(2*c[i].ai)+c[i].di;
     if(q[t]-q[c[i].di]){
      cnt++;
      t2=max(t2,c[i].di);
      t3=min(t3,t);
     }
    }
   }
  }
  cout<<cnt;
  for(int i=1;i<=m;i++){
   if(p[i]>=t1&&t1>0&&((t2==0||t3==INT_MAX)||(p[i]<=t2||p[i]>=t3))||(p[i]>=t2&&t2>0&&p[i]<t3&&t3<INT_MAX)){
    ans++;
   }
  }
  cout<<" "<<ans<<endl;
 }
 return 0;
}
